package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-09-13  18:46
 */
public class Test {
    public int missingNumber(int[] nums) {
        int arrSum = 0;
        int n = nums.length;
        int total = n * (n + 1) / 2;
        for (int i = 0; i < nums.length; i++) {
            arrSum += nums[i];
        }
        return total - arrSum;
    }

    public static void main(String[] args) {
        int[] nums = {0,1,2,3,4,5,7,8};
        Test test = new Test();
       int ret = test.missingNumber(nums);
        System.out.println(ret);
    }
}
